package com.hhkj.admin.sale.model.dopo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.hutool.core.util.ObjectUtil;
import com.hhkj.admin.sale.common.cont.SaleCommissionConst;
import com.hhkj.admin.sale.domain.SaleCommission;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class SaleCommissionPo extends SaleCommission {

    /** 订单编号 **/
    @Excel(name = "订单号", orderNum = "0", width = 30)
    private String orderNum;

    /** 支付时间 **/
    @Excel(name = "支付时间", orderNum = "1", width = 30, databaseFormat = "yyyy-MM-dd hh:mm")
    private String payTime;

    /** 付款金额 **/
    @Excel(name = "付款金额", orderNum = "2", width = 30, type = 10, numFormat = "#,##0.00")
    private BigDecimal payPrice;

    @Excel(name = "商家名称", orderNum = "6", width = 30)
    private String sale;

    @Excel(name = "商家级别", orderNum = "7", width = 30)
    private String saleLevel;

    /** 成交商家 **/
    private String dealSale;

    /** 成交商家id **/
    private Long dealSaleId;

    /** 成交销售名称 **/
    private String dealSaleName;

    /** 成交销售编号 **/
    private String dealSaleNum;

    /** 退款状态 **/
    private String refundStatusCode;

    public String getSale() {
        return getSaleName() + "(" + getSaleNum() + ")";
    }

    public String getDealSale() {
        String dealSaleName = getDealSaleName();
        String dealSaleNum = getDealSaleNum();
        if (ObjectUtil.isNotEmpty(dealSaleName) && ObjectUtil.isNotEmpty(dealSaleNum)) {
            return dealSaleName + "(" + dealSaleNum + ")";
        }
        return "";
    }

    public String getSaleLevel() {
        if(getLevelCode().equals(SaleCommissionConst.LevelCode.THIS_LEVEL.getCode())) {
            return "本级商家";
        } else {
            return "上级商家";
        }
    }
}
